const path = require("node:path");
const fs = require("fs-extra");
const {exiftool} = require("exiftool-vendored");


async function processThis(filePath){
    try {
        const metaData = await exiftool.read(filePath)
        const date = metaData.CreateDate
        const filename = path.basename(filePath)
        console.log('___','filename',filename,date ? `${date.year}-${date.month}-${date.day}` : `${date}`)
    } catch (err) {

    }
}

async function viewFiles(dict){
    const files = await fs.readdir(dict)
    for(const file of files){
        const filePath = path.join(dict,file);
        const stats = await fs.stat(filePath);

        if(stats.isDirectory()){
            await viewFiles(filePath)
        }else {
            await processThis(filePath)
        }
    }
}


async function main(){
    const filesPath = path.resolve(__dirname,'../images');
    await viewFiles(filesPath)
    await exiftool.end()
}

main()
